﻿@model IEnumerable<INTREPWEB.Models.Agente>
@{
    ViewBag.Title = "Agentes";

    if (IsAjax)
    {
        Layout = null;
    <script type="text/javascript" src="@Url.Content("~/Scripts/intrep-agente.js")" ></script>
    }
}
@Html.Partial("_ToolBar")
@if (ViewBag.Vazio == null)
{
    <table>
        <tr>
            <th>
                Nome
            </th>
            <th>
                CNPJ
            </th>
            <th>
                Endereco
            </th>
            <th>
                CEP
            </th>
            <th>
                Cidade
            </th>
            <th>
                Responsavel
            </th>
            <th>
                Telefone
            </th>
            <th>
                Email
            </th>
            <th>
            </th>
        </tr>
        @foreach (var item in Model)
        {
            <tr>
                <td>
                    @Ajax.ActionLink(item.Nome, "Editar", new { id = item.Id }, new AjaxOptions { OnBegin = "criaModal('editaragente')", UpdateTargetId = "editaragente", OnSuccess = "$.modalPopup('editaragente')" })
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.CNPJ)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Endereco)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.CEP)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Cidade)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Responsavel)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Telefone)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Email)
                </td>
                <td>
                    @Ajax.ActionLink("x", "Deletar", new { id = item.Id }, new AjaxOptions { OnBegin = "criaModal('deletaragente')", UpdateTargetId = "deletaragente", OnSuccess = "$.modalPopup('deletaragente')" })
                </td>
            </tr>
        }
    </table>    
}
else
{
    @Html.Partial("_SemItens")
}